package com.ecoolex.hotel.saas.api.graphql;

import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.web.api.graphql2.annotation.GraphQL2Module;
import com.ecoolex.framework.web.api.graphql2.annotation.QueryField;
import com.ecoolex.framework.web.api.graphql2.annotation.Source;
import com.ecoolex.framework.web.api.graphql2.annotation.TypeField;
import com.ecoolex.hotel.saas.entity.Store;
import com.ecoolex.hotel.saas.entity.StoreMarketing;
import com.ecoolex.hotel.saas.ws.StoreMarketingService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.lang.NonNull;

import java.util.List;

@GraphQL2Module(type = GraphQL2Module.Type.User, description = "商户首页营销")
public class StoreMarketingGraphql {

    @Reference
    private StoreMarketingService storeMarketingService;

    @TypeField(type = Store.class, field = "storeMarketingList", description = "关联的商户首页营销")
    public List<StoreMarketing> storeMarketingList(@Source Store source, @NonNull Integer size){
        return storeMarketingService.query(source.getStoreId(),size);
    }

    @QueryField(field = "storeMarketing", description = "商户首页营销")
    public StoreMarketing get(@NonNull Integer id){
        return storeMarketingService.get(id);
    }

    @QueryField(field = "storeMarketingList", description = "商户首页营销列表")
    public Pagination<StoreMarketing> query(String name, @NonNull Integer storeId, @NonNull Page page){
        return storeMarketingService.query(name,storeId,page);
    }
}
